package com.push.web.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.push.common.annotation.Log;
import com.push.common.core.controller.BaseController;
import com.push.common.core.domain.AjaxResult;
import com.push.common.enums.BusinessType;
import com.push.web.domain.BizBibInfo;
import com.push.web.service.IBizBibInfoService;
import com.push.common.utils.poi.ExcelUtil;
import com.push.common.core.page.TableDataInfo;

/**
 * 文献Controller
 *
 * @author yanxi
 * @date 2022-10-10
 */
@RestController
@RequestMapping("/intelligence/bibinfo")
public class BizBibInfoController extends BaseController
{
    @Autowired
    private IBizBibInfoService bizBibInfoService;

    /**
     * 查询文献列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:bibinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizBibInfo bizBibInfo)
    {
        startPage();
        List<BizBibInfo> list = bizBibInfoService.selectBizBibInfoList(bizBibInfo);
        return getDataTable(list);
    }

    /**
     * 导出文献列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:bibinfo:export')")
    @Log(title = "文献", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizBibInfo bizBibInfo)
    {
        List<BizBibInfo> list = bizBibInfoService.selectBizBibInfoList(bizBibInfo);
        ExcelUtil<BizBibInfo> util = new ExcelUtil<BizBibInfo>(BizBibInfo.class);
        return util.exportExcel(list, "文献数据");
    }

    /**
     * 获取文献详细信息
     */
    @PreAuthorize("@ss.hasPermi('intelligence:bibinfo:query')")
    @GetMapping(value = "/{bibId}")
    public AjaxResult getInfo(@PathVariable("bibId") String bibId)
    {
        return AjaxResult.success(bizBibInfoService.selectBizBibInfoByBibId(bibId));
    }

    /**
     * 新增文献
     */
    @PreAuthorize("@ss.hasPermi('intelligence:bibinfo:add')")
    @Log(title = "文献", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizBibInfo bizBibInfo)
    {
        return toAjax(bizBibInfoService.insertBizBibInfo(bizBibInfo));
    }

    /**
     * 修改文献
     */
    @PreAuthorize("@ss.hasPermi('intelligence:bibinfo:edit')")
    @Log(title = "文献", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizBibInfo bizBibInfo)
    {
        return toAjax(bizBibInfoService.updateBizBibInfo(bizBibInfo));
    }

    /**
     * 删除文献
     */
    @PreAuthorize("@ss.hasPermi('intelligence:bibinfo:remove')")
    @Log(title = "文献", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bibIds}")
    public AjaxResult remove(@PathVariable String[] bibIds)
    {
        return toAjax(bizBibInfoService.deleteBizBibInfoByBibIds(bibIds));
    }
}
